<?php
class Contas_model extends CI_Model
{
	public function __construct()
	{
		parent::__construct();
	}
	
	public function getContas($limit, $offset, $params=NULL)
	{
        $this->db->flush_cache();
		$this->db->start_cache();		
		$response = null;

		if(!empty($params) && !is_null($params))
		{
		    $this->db->like('nome_fantasia', $params); 
		}
		
		$this->db->from("tb_contas");
		$this->db->where("flag_deletado =", "N");
		$response->countAll = $this->db->count_all_results();
		
		$this->db->order_by("nome_fantasia", "ASC");
		
		$this->db->limit($limit,$offset);
		$query = $this->db->get("tb_contas");
		$data = $query->result();
		$response->query = $data;
		$this->db->flush_cache();
		return $response;
	}
}